using UnityEngine;
using System.Collections;

public class Intro : MonoBehaviour {
	// Use this for initialization
	public Texture startGameActive;
	public Texture startGameInactive;
	public Texture creditsActive;
	public Texture creditsInactive;
	public Texture exitActive;
	public Texture exitInactive;
	
	Rect startGameActiveRect;
	Rect creditsActiveRect;
	Rect exitActiveRect;
	
	Texture startGameTex;
	Texture creditsTex;
	Texture exitTex;
	
	void Start () {
		float middle_x = (Screen.width/2);
		float middle_y = (Screen.height/2);
		
		startGameActiveRect = new Rect(middle_x-128,middle_y-32,264,52);
		creditsActiveRect = new Rect(middle_x-128,middle_y-32 + 70,264,52);
		exitActiveRect = new Rect(middle_x-128,middle_y-32 + 140,264,52);
		
		startGameTex = startGameInactive;
		creditsTex = creditsInactive;
		exitTex = exitInactive;
	}
	
	// Update is called once per frame
	void Update () {
	}
	
	void OnGUI () {
		Vector2 mouse = Input.mousePosition;
		
		if (startGameActiveRect.Contains(new Vector2(mouse.x, Screen.height - mouse.y))) {
			startGameTex = startGameActive;
		}
		else
		{
			startGameTex = startGameInactive;
		}
		
		if (creditsActiveRect.Contains(new Vector2(mouse.x, Screen.height - mouse.y))) {
			creditsTex = creditsActive;
		}
		else
		{
			creditsTex = creditsInactive;
		}
		
		if (exitActiveRect.Contains(new Vector2(mouse.x, Screen.height - mouse.y))) {
			exitTex = exitActive;
		}
		else
		{
			exitTex = exitInactive;
		}
		
		
		if(GUI.Button(startGameActiveRect, startGameTex, GUIStyle.none)) {
			Application.LoadLevel("Scene00");
		}
		if(GUI.Button(creditsActiveRect, creditsTex, GUIStyle.none)) {
		    Application.LoadLevel("Credits");
		}
		
		if(GUI.Button(exitActiveRect, exitTex, GUIStyle.none))
		{
			//só fecha quando cria o build
			Application.Quit();
		}					
	}
}
